package com.oa.service.impl;

import com.oa.mapper.PartyMapper;
import com.oa.pojo.Party;
import com.oa.pojo.Property;
import com.oa.service.PropertyService;
import com.oa.mapper.PropertyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 14541
* @description 针对表【property】的数据库操作Service实现
* @createDate 2023-10-27 10:52:05
*/
@Service
public class PropertyServiceImpl implements PropertyService{
    @Autowired
    private PropertyMapper propertyMapper;

    @Override
    public int delete(Property property) {
        int ppvalue=0;
        Property property1=new Property();
        property1.setId(property.getId());
        List<Property> pplist=new ArrayList<>();
        pplist=select(property1);
        if(pplist.size()>=1){
            ppvalue=propertyMapper.delete(property);
        }else{
            ppvalue=-1;
        }
        return ppvalue;
    }
    @Override
    public int update(Property property) {
        int ppvalue=0;
        Property property1=new Property();
        property1.setId(property.getId());
        List<Property> pplist=new ArrayList<>();
        pplist=select(property1);
        if(pplist.size()>=1){
            ppvalue=propertyMapper.update(property);
        }else{
            ppvalue=-1;
        }
        return ppvalue;
    }
    @Override
    public int insert(Property property){
        int ppvalue=0;
        Property property1=new Property();
        property1.setId(property.getId());
        List<Property> pplist=new ArrayList<>();
        pplist=select(property1);
        if(pplist.size()>=1){
            ppvalue=-1;
        }else{
            ppvalue=propertyMapper.insert(property);
        }
        return ppvalue;
    }
    @Override
    public List<Property> select(Property property){
        return propertyMapper.select(property);
    }
}




